import type { IResPageList } from '@/utils/request';
import type { TableColumns } from '@/components/TablePro';

export const tableColumns: TableColumns = [
	{ title: '姓名', key: 'name', dataIndex: 'name', width: 200 },
	{ title: '年龄', key: 'age', dataIndex: 'age', width: 300 },
	{ title: '操作', key: 'handler', width: 300 }
];

interface Item {
	id: number;
	name: string;
	age: number;
}

export const mockSelectListPage = (data: { pageNo: number; pageSize: number }) => {
	const { pageNo, pageSize } = data;
	const resultsList: Item[] = [];

	for (let i = pageNo; i < 10 + pageNo; i++) {
		const uid = (pageNo - 1) * (pageSize - 1) + i;
		resultsList.push({ id: uid, name: `name ${i}`, age: i + 5 });
	}

	return new Promise<IResPageList>((resolve) => {
		setTimeout(() => {
			resolve({
				code: 200,
				message: 'success',
				data: {
					pageCount: 10,
					pageNo,
					pageSize,
					totalCount: 30,
					results: resultsList
				}
			});
		}, 500);
	});
};
